<template>
  <div class="user frame_content">
    <div class="user_search">
      <div class="searchs">
        <input
          type="text"
          name="Name"
          placeholder="搜索昵称"
          style="margin-left: 5px"
          v-model="name"
        />
      </div>
      <a href="javascript:void(0);" @click="query(1)" class="searchBtn">昵称</a>
      <div class="searchs">
        <input
          type="text"
          name="Name"
          placeholder="搜索id"
          style="margin-left: 5px"
          v-model="id"
        />
      </div>
      <a href="javascript:void(0);" @click="query(0)" class="searchBtn">id</a>
    </div>
    <table class="user_table context" style="margin-bottom: 40px">
      <thead>
        <tr>
          <th>用户昵称</th>
          <th>头像</th>
            <th>房间</th>
            <th>代理</th>
          <th>id</th>
          <th>openID</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item,index) in userList.data" :key="index">
          <td>{{item.nickname}}</td>
          <td>
            <img style="width:40px;height:40px;" class="wxImg" :src="item.logo" />
          </td>
            <td>{{item.ra_nickname}}</td>
            <td>{{item.aa_nickname}}</td>
          <td>{{item.id}}</td>
          <td>{{item.openId}}</td>
        </tr>
      </tbody>
    </table>
    <div style="text-align:center">
      <el-pagination
        prev-text="上一页"
        next-text="下一页"
        @current-change="currChange"
        background
        layout="prev, pager, next"
        :total="userList.total"
        :page-size="userList.per_page"
        :current-page.sync="userList.current_page"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { mapState, mapActions } from "vuex";
import http from "@/utils/http";
export default {
  data() {
    return {
      name:"",
      id:"",
      lists:"",
      page:""
    };
  },
  computed: {
    ...mapState("user", [
      "userList",
    ])
  },
  methods: {
    ...mapActions("user", [
      "getUserList", //用户点击查询
    ]),
    // 搜索查询
    query(a) {
      let token=sessionStorage.getItem('token');
      let id, nickname;
      if(a===1){ //昵称
      this.id="";
      this.page=""
      // nickname=this.name;
      }else if(a===0){
        this.name="";
        this.page=""
      }
      this.wx_date();
    },
    wx_date(){
      let id=this.id;
      let nickname=this.name;
      let page=this.page;
      this.getUserList({id,nickname,page})
    },
    currChange(val){//页码
      // console.log(`当前页: ${val}`);
      this.page = val;
      this.id="";
      this.name="";
      this.wx_date();
    }
  },
  created() {
    this.wx_date()
  }
};
</script>

<style>
.user {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 20px;
  color: #333;
  background-color: #fff;
}
.user_search {
  width: 95%;
  height: 30px;
  border-bottom: 1px solid #ddd;
  border-radius: 10px;
  margin: 20px auto 10px;
  min-width: 1600px;
}
.user_search input,
.user_search button,
div.sort,
div.searchs {
  display: inline-block;
  vertical-align: top;
}
.searchs input {
  width: 160px;
}
.user #sort {
  height: 24px;
  width: 220px;
  margin-left: 2px;
  margin-bottom: 6px;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.user_search a {
  height: 25px;
  line-height: 25px;
  margin: 0 10px;
  text-decoration: none;
}
.user td a:hover {
  color: #005580;
  text-decoration: underline;
}
.user_search .searchBtn {
  width: 40px;
  height: 22px !important;
  border: 1px solid #9b9b9b;
  background-color: #e1e1e1;
  text-align: center;
  color: #333;
  display: inline-block;
}
.searchBtn:hover,
.searchBtn:focus {
  color: #005580;
  text-decoration: none;
}
.user_table {
  min-width: 1600px;
  width: 96%;
  margin: auto;
  border: 1px solid #ddd;
  border-collapse: separate;
  border-left: 0;
  border-spacing: 0;
}
.user_table th,
.user_table td {
  border-top: 1px solid #ddd;
}

.context th {
  background-color: #eaeaea;
  font-weight: bold;
}
.dropdown-menu1 label {
  margin-left: 4px;
}
.dropdown-menu1 input {
  margin: 4px 0 0;
  line-height: normal;
}
.context td,
.context th {
  padding-top: 8px;
  padding-bottom: 4px;
  line-height: 20px;
  border-left: 1px solid #ddd;
  text-align: center;
}
.context tbody tr:hover > td,
.context tbody tr:hover > th {
  background-color: #f5f5f5;
}
.user_table td a {
  text-decoration: none;
  color: #08c;
}
.user_img {
  padding-left: 8px;
}
.user td img {
  display: block;
  width: 30px;
  height: 30px;
}

.btnWrap span {
  margin: 0 4px;
}
.user .btn:hover,
.btn:focus {
  color: #333;
  text-decoration: none;
  background-position: 0 -15px;
}
.user .btn {
  background-color: #f5f5f5;
}
.btn.active,
.btn:active {
  background-image: none;
  outline: 0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
}
.layui-layer {
  top: 150px;
  left: 0;
  margin: 0;
  padding: 0;
  background-color: #fff;
  border-radius: 2px;
  box-shadow: 1px 1px 50px rgba(0, 0, 0, 0.3);
}
.layui-layer-title {
  padding: 0 80px 0 20px;
  height: 42px;
  line-height: 42px;
  border-bottom: 1px solid #eee;
  font-size: 14px;
  color: #333;
  overflow: hidden;
  background-color: #f8f8f8;
  border-radius: 2px 2px 0 0;
}
.layui-layer,
.layui-layer-shade {
  position: fixed;
  margin-top: 145px;
  pointer-events: auto;
}
.layui-layer-page .layui-layer-content {
  position: relative;
  overflow: auto;
}
.layerModel {
  height: 100%;
}
#model2 .wrap,
#model3 .wrap,
#model4 .wrap {
  padding: 10px 0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 20px;
  color: #333;
}
.layerModel .wrap {
  /* border: 3px solid #405594; */
  box-sizing: border-box;
  height: 100%;
  border-top: none;
  overflow-y: auto;
}
.layerModel table {
  width: 94%;
  margin: 0 auto;
  border: 1px solid #ccc;
  line-height: 28px;
  font-size: 14px;
  text-align: center;
}
#model2Pages,
#model1Pages {
  text-align: center;
  padding-top: 5px;
}
.layerModel table th {
  background-color: #eaeaea;
}
.layerModel table th,
.layerModel table td {
  border: 1px solid #ccc;
}
.layui-layer-shade {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.layui-layer-setwin {
  position: absolute;
  right: 15px;
  *right: 0;
  top: 15px;
  font-size: 0;
  line-height: initial;
}
.layui-layer-setwin {
  top: 8px !important;
}
.layui-layer-setwin .layui-layer-close1 {
  background-position: 1px -40px;
  cursor: pointer;
}
.layui-layer-setwin a {
  position: relative;
  width: 16px;
  height: 16px;
  margin-left: 10px;
  font-size: 12px;
  _overflow: hidden;
}
.layui-layer-btn a,
.layui-layer-dialog .layui-layer-ico,
.layui-layer-setwin a {
  display: inline-block;
  vertical-align: top;
}
.layui-layer-ico {
  background: url(../../images/icon.png) no-repeat;
}
#model5 .model1H label {
  display: inline-block;
  line-height: 32px;
  margin-bottom: 0;
  padding: 5px 0 5px 10px;
}
#model5 .model1H label #dateinfo2,
#model5 .model1H label #dateinfo3 {
  width: 111px;
}
#model5 .model1H label .perInput {
  width: 70px;
}
#model1 .model1H label input,
#model5 .model1H label input {
  vertical-align: inherit;
  margin-bottom: 0;
}
#model1 .sBtn,
#model5 .sBtn {
  width: 40px;
  height: 20px;
  border: 1px solid #9b9b9b;
  background-color: #e1e1e1;
  text-align: center;
  line-height: 20px;
  color: #333;
  display: inline-block;
  text-decoration: none;
  margin-left: 2px;
}
.layerModel table {
  width: 94%;
  margin: 0 auto;
  border: 1px solid #ccc;
  line-height: 28px;
  font-size: 14px;
  text-align: center;
}
#model5 td {
  padding-left: 5px;
}
.layerModel table th,
.layerModel table td {
  border: 1px solid #ccc;
}
.wid1 {
  float: left;
  width: 60%;
  text-align: left;
}
.wid2 {
  display: inline-block;
  width: 40%;
  text-align: left;
}
.fr {
  float: right;
}
.red {
  color: red;
}
#model1 .totalUpDown {
  font-size: 14px;
  color: #333;
  line-height: 22px;
  margin: 0;
  padding-left: 20px;
  padding-bottom: 10px;
}
#model1 .model1H label {
  display: inline-block;
  line-height: 32px;
  margin-bottom: 0;
  padding: 5px 0 5px 20px;
}
#model1 .model1H label input,
#model5 .model1H label input {
  height: 24px;
}
.el-date-editor.el-input,
.el-date-editor.el-input__inner {
  width: 200px;
}
</style>
